package cn.ctyun.xstore.s3.client;

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.securitytoken.AWSSecurityTokenService;
import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder;

import cn.ctyun.xstore.s3.Conf;

public class AwsSTSClientBuilder {


    public static AWSSecurityTokenService buildSTSClient() {
        BasicAWSCredentials credentials = new BasicAWSCredentials(Conf.ACCESS_KEY, Conf.SECRET_KEY);
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration(Conf.END_POINT, Regions.DEFAULT_REGION.getName());
        return AWSSecurityTokenServiceClientBuilder.standard()
                .withCredentials(new AWSStaticCredentialsProvider(credentials))
                .withEndpointConfiguration(endpointConfiguration)
                .build();
    }

}
